/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd. 		   */
/*																   */
/*	NAME	  = t__sqlserver_bigint_add.c						   */
/*	NOTE	  = 												   */
/*	DATE	  = 2016/04/07 by songbb							   */
/*******************************************************************/

#include <stdio.h>
#include <string.h>
#include <CUnit/Basic.h>

#include <sybase/config.h>
#include <sybase/sybase_core.h>

extern int __sybase_merge_string(char *p_first_str
                                , char *p_second_str
                                , char **pp_merge_str);

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

static void __case1(void)
{
    char *p_first_str = frstrdup("123");
    char *p_second_str = frstrdup("abc");
    char *p_str = NULL;

    int i_ret = __sybase_merge_string(p_first_str, p_second_str, &p_str);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_STRING_EQUAL(p_str, "123;abc")
    frfree(p_str);
    return;
}

static void __case2(void)
{
    char *p_first_str = frstrdup("123");
    char *p_second_str = frstrdup("abc");

    int i_ret = __sybase_merge_string(p_first_str, p_second_str, &p_second_str);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_STRING_EQUAL(p_second_str, "123;abc")
    frfree(p_second_str);
    return;
}

static void __case3(void)
{
    char *p_first_str = frstrdup("123");
    char *p_second_str = frstrdup("abc");
    char *p_str = NULL;

    int i_ret = __sybase_merge_string(p_first_str, p_second_str, &p_str);

    CU_ASSERT_EQUAL(i_ret, APM_L7_ANALYZE_SUCC);
    CU_ASSERT_STRING_EQUAL(p_str, "123;abc")
    frfree(p_str);
    return;
}

int add_suite__sybase_merge_string(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __sybase_merge_string()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    //增加测试用例
    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL ||
        CU_add_test(pSuite, "case3", __case3) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
